package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/1/18
 * Time:18:18
 **/
public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入归还图书名字：");
        String name = scanner.nextLine();

        for (int i = 0; i < bookList.getSize(); i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                //找到此书了
                book.setState(false);
                System.out.println(book);
                return;
            }
        }
        System.out.println("未找到！");
    }
}
